package com.neuedu.learn;

public class Demo6 {

    /**
     * 运算  位运算
     * @param arg
     */
    public static void main(String arg[]){

        /**
         *  十进制       0       1       2      3         4            5          6            7           8           9
         *          0000       0001    0010    0011     0100       0101         0110        0111         1000         1001
         */

            int  numa = 4;  //  0 1 0 0
            int  numb = 5;  //  0 1 0 1
                          // &  0 1 0 0
                          // |  0 1 0 1

        System.out.println("(numa &  numb) = " + (numa & numb)); // 4
        System.out.println("(numa |  numb) = " + (numa | numb)); // 5
        System.out.println("(numa ^  numb) = " + (numa ^ numb)); // 1
        System.out.println("( ~ 5) = " + (~5)); // -6


        System.out.println("(numa << 2) = " + (numa << 2));  //  0 1 0 0        0 1 0 0 0
        System.out.println("(numa >> 1) = " + (numa >> 1));  //  0 1 0 0         0 0 1 0


        int numc =  -8;

        System.out.println("(numc >>> 1) = " + (numc >>> 1));  //

    }





}
